package com.wr.service.impl;

import com.wr.dao.EmailCodeEntityMapper;
import com.wr.model.EmailCodeEntity;
import com.wr.service.EmailService;
import com.wr.utils.PageInfo;
import org.apache.ibatis.session.RowBounds;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2016/12/9 0009.
 */

@Service
public class EmailServiceImpl implements EmailService {

    @Resource
    private EmailCodeEntityMapper emailCodeEntityMapper;

    @Override
    public EmailCodeEntity selectByEmail(String email) {
        List<EmailCodeEntity> list = emailCodeEntityMapper.selectByEmail(email);
        if(list.size() > 0){
            return list.get(0);
        }
        return null;
    }

    @Override
    public List<EmailCodeEntity> selectCodeList(PageInfo pageInfo) {
        pageInfo.setCount(emailCodeEntityMapper.countCodeList());
        return emailCodeEntityMapper.selectCodeList(new RowBounds(pageInfo.getOffset(),pageInfo.getPageSize()));
    }

    @Override
    public void insertEmailCode(EmailCodeEntity emailCodeEntity) {

        emailCodeEntityMapper.insertEmailCode(emailCodeEntity);
    }

    @Override
    public void updateEmailCode(EmailCodeEntity emailCodeEntity) {

        emailCodeEntityMapper.updateEmailCode(emailCodeEntity);
    }

    @Override
    public void deleteEmailCode(int id) {

        emailCodeEntityMapper.deleteEmailCode(id);
    }

}
